<?PHP

class SiteBO extends BusinessObject{
  /* private function using in constructors*/
  function setAttributes(){
    $this->fields   = array(
			"id"                =>	"site_id",
			"url"               =>	"site_url",
			"name"		    =>	"site_name",
			"tmpl"              =>	"site_tmpl",
			"disabled"          =>	"site_disabled",			
			"deleted"           =>	"site_deleted"
		);

    BusinessObject::setAttributes();
  }
  /* constuctor */
  function SiteBO(){
    /** super(tableName) */
    BusinessObject::BusinessObject("sites");
    $this->setAttributes();
  }

  /*  Save  */
  function Save($siteID){
    if(is_numeric($siteID) && $siteID<>0)
    {
      $this->id = "$siteID";
      $this->Update("{$this->fields[id]} = '$siteID'");  
    } else{
      $this->Insert();
      $this->id = $this->getInsertID();
    }
  }
  
  function checkUrl(){
    $u = new SiteBO();
    $u->url = $this->url;
	  $u->deleted = 0;
    $u->Load(0,1);
    if($u->Next()){
      if($u->id != $this->id) return(false);
    }
    return(true);
  }
}
?>
